/*
 * Copyright (C) hushenglan
 */

#ifndef _COMMON_LOG_H_
#define _COMMON_LOG_H_

namespace common
{

#ifdef DEBUG_PRINT
    #define MS_DEBUG(format,args...) \
                printf(format,##args)
#else
    #define MS_DEBUG(format,args...)
#endif

/*
 * 日志级别
 */
enum
{
    FATAL = 1,
    ERROR,
    WARN,
    INFO,
    DEBUG,
};

class CLog
{
public:

    /*
     * 构造函数
     */
    CLog();

    /*
     * 析构函数
     */
    virtual ~CLog();

    /*
     * log单例
     */
    static CLog* Instance();

    /*
     * 打印log
     */
    int log(int level, const char *format, ...);

    /*
     * 打印access
     */
    int access(const char *format, ...);

    /*
     * 打印pid
     */
    int pid(const char *format, ...);

    /*
     * 打印字符串
     */
    int print(ms_uchar_t *data, int len);

private:

    static CLog* _instance;

};

}

#endif
